<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>参考资料</title>
@include('common-css')
<style>
.input_box {
    width: 100%;
    height: 40px;
    margin-top: 15px;
    margin-bottom: 15px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.input_label {
    width: 120px;
    box-sizing: border-box;
}

.fileicon {
    width: 16px;
    vertical-align: middle;
}
</style>
</head>
<body>
<div id="app">

</div>

</body>
</html>

<script id="appTemplate" type="x-template">
<a-locale-provider :locale="antdLocale">
    <div class="container">
        @include('home.header')

        <main>
            <div class="common_container">

                @include('home.aside', ['selectedItem' => 'docs'])

                <div class="common_content">
                    <div class="common_box">
                        <a-table :dataSource="docs" :pagination="false" width="50%" rowKey="id">
                            <a-table-column title="序号" dataIndex="num" width="90px">
                            </a-table-column>
                            <a-table-column title="文件名">
                                <template slot-scope="row">
                                    <img class="fileicon" :src="row.name | fileicon"/>
                                    <a :href="row.volatile_url" target="_blank">@{{row.name}}</a>
                                </template>
                            </a-table-column>
                        </a-table>
                    </div>
                </div>
            </div>
        </main>
    </div>

</a-locale-provider>
</script>

@include('common-js')

<script>
var docs = {!! json_encode($docs, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) !!};
var num = 1
docs.forEach(item => {
    item.num = num
    num += 1
    item.volatile_url = item.url + "?timestamp={{ time() }}"
})

Vue.prototype.$axios = axios
var app = new Vue({
    el: '#app',
    template: '#appTemplate',
    data: {
        changePasswordDialogVisible: false,
        passwordInfo: {
            password: '',
            passwordConfirm: ''
        },
        docs: docs,
        antdLocale: antd.locales.zh_CN
    },
    mounted() {
    },
    methods: {
        handleHeaderDropdownItemClick: handleHeaderDropdownItemClick,
        handleChangePasswordOk: handleChangePassword,
        handleOrgBusinessLicensePhotoBeforeUpload(file) {
            console.log('handleOrgBusinessLicensePhotoBeforeUpload', file)
            var filename = file.name.toLowerCase()
            if (filename.endsWith('.jpg') || filename.endsWith('.jpeg') || filename.endsWith('.png')) {
                antd.message.loading('正在上传...', 0)
                return true
            } else {
                antd.message.warn('不允许上传该文件格式')
                return false
            }
        },
        handleOrgBusinessLicensePhotoUploadChange(event) {
            console.log('handleOrgBusinessLicensePhotoUploadChange', event)
            if (event.file.status == 'done') {
                antd.message.destroy()
                if (event.file.response.ok) {
                    let photo_path= event.file.response.url
                    axios.post('/api/auth/reupload-org-bizlic-Photo', {photo_path})
                        .then(res => {
                            antd.message.success('上传成功')
                            history.go(0)
                        })
                } else {
                    antd.message.warn('上传失败')
                }
            }
        },
    },
    filters: {
        fileicon(value) {
            var value = value.toLowerCase()
            if (value.endsWith('.txt')) {
                return '/images/fileicon/txt.png'
            } else if (value.endsWith('.zip')) {
                return '/images/fileicon/txt.png'
            } else if (value.endsWith('.pdf')) {
                return '/images/fileicon/pdf.png'
            } else if (value.endsWith('.doc') || value.endsWith('.docx')) {
                return '/images/fileicon/word.png'
            } else if (value.endsWith('.xls') || value.endsWith('.xlsx')) {
                return '/images/fileicon/excel.png'
            } else if (value.endsWith('.ppt') || value.endsWith('.pptx')) {
                return '/images/fileicon/ppt.png'
            }
            return '/images/fileicon/url.png'
        }
    }
})
</script>